<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

<div class="am-progress am-progress-striped am-progress-sm am-active ">
    <div class="am-progress-bar am-progress-bar-secondary"  style="width: 10%"></div>
</div>

<a class="am-btn am-btn-primary" href="addStudent.html">添加学生</a>
<table class="am-table">
    <thead>
    <tr>
        <th>学号</th>
        <th>姓名</th>
        <th>性别</th>
        <th>生日</th>
        <th>入学日期</th>
        <th>手机号码</th>
    </tr>
    </thead>
    <tbody>


    <?php foreach ($students as $stu){ ?>
        <tr>
            <td><?php echo $stu['stud_id']   ?></td>
            <td><?php echo $stu['stud_name']   ?></td>
            <td><?php echo $stu['stud_sex']   ?></td>
            <td><?php echo $stu['birth_date']   ?></td>
            <td><?php echo $stu['entry_date']   ?></td>
            <td><?php echo $stu['mobile']   ?></td>
            <td>
                <a href="index.php?a=student&f=edit&id=<?php echo $stu['stud_id'];   ?>" >编辑</a>
                <a href="index.php?a=student&f=delete&id=<?php echo $stu['stud_id'];   ?>" >删除</a>
            </td>
        </tr>
    <?php } ?>
    </tbody>
</table>


<ul class="am-pagination am-pagination-centered">

    <?php
    $prev = $page - 1;
    echo "<li><a href=\"index.php?a=Student&f=userlist&page=1\">首页</a></li>";
    //判断是否为第一页
    if($page == 1){
        echo "<li class=\"am-disabled\" ><a href='#' >&laquo;</a></li>";
    }else{
        echo "<li ><a href=\"index.php?a=Student&f=userlist&page=$prev\">&laquo;</a></li>";
    }

    //循环页码
    //    for($i=1;$i<=$count_page;$i++) {
    //        if ($page == $i) {
    //            echo "<li class=\"am-active\" ><a  href=\"index.php?page=$i\">第{$i}页</a></li>";
    //        } else {
    //            echo "<li><a  href=\"index.php?page=$i\">第{$i}页</a></li>";
    //        }
    //    }

    //    echo "<li><a  href=\"index.php?page=".($page-2)."\"  > 第".($page-2)."页</a></li>";
//    echo "<li class=\"am-active\" ><a    href=\"index.php?a=Student&f=userlist&page=$page\">第{$page}页</a></li>";
    //    echo "<li><a  href=\"index.php?page={$page+1}\">第{$page+1}页</a></li>";
    //    echo "<li><a  href=\"index.php?page={$page+2}\">第{$page+2}页</a></li>";

    for($i=3; $i>=1; $i--) {
        if(($page - $i) < 1 ) { // 当前页右边最多 bothnum 个数字
            continue;
        }
        $ss = ($page - $i);
        echo "<li><a href='index.php?a=student&f=userlist&page={$ss}' >{$ss}</a></li>";
    }
    //当前页
    echo '<li class="am-active"><a href="index.php?a=student&f=userlist&page='.($page + $i).'">'.$page.'</a></li>';

    for($i=1; $i<=3; $i++) {
        if(($page + $i) > $count_page) { // 当前页右边最多 bothnum 个数字
            break;
        }
        $ss = ($page + $i);
        echo "<li><a href='index.php?a=student&f=userlist&page={$ss}' >{$ss}</a></li>";
    }





    //判断是否为最后一页
    $next = $page + 1;
    if($page == $count_page){
        echo "<li class=\"am-disabled\"><a href=\"#\">&raquo;</a></li>";
    }else{
        echo "<li><a href=\"index.php?a=Student&f=userlist&page=$next\">&raquo;</a></li>";
    }

    echo "<li><a href=\"index.php?a=Student&f=userlist&page=$count_page\">尾页</a></li>";

    ?>
</ul>